<?php
namespace houze;

/**
 * Git库操作类
 */ 

class Git{
    // gitee自动部署 *注意要在后台添加webhook免密拉取设置好回调url  只要push gitee后台自动向设置的url post回调请求
    public static function gitee_pull(){
        $config = \houze\Config::get('git.gitee');
        $param = \houze\Request::param();

        //获取webhook配置的 目录 cd到目录执行git pull
        array_unshift($config['cmd'],"cd ".$param['list']);
        array_push($config['cmd'],"chown -R www:www ".$param['list']);
        array_push($config['cmd'],"chmod -R 755 ".$param['list']);
        echo "**************************************************************************".PHP_EOL;
        $cmd = implode(" && ", $config['cmd']);//拼接shell成一条一次性执行
        $info = exec($cmd);
        var_dump($info);//打印执行结果
        echo "===执行完成".date('Y-m-d H:i',time())."===". PHP_EOL;
    }
}